<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="cn.sumpu.app.guoguojie.domain.AdminUser,cn.sumpu.app.guoguojie.web.util.AdminUtil" %>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<script type="text/javascript" src="/thirdparty/My97DatePicker/WdatePicker.js"></script>
<%
	request.setAttribute("name", AdminUtil.getRealname());
%>
<script type="text/javascript">
	var productArray = new Array();
	var product = null;
	var productGrid = null;
	$(function(){
		productGrid = $("#product_grid").ligerGrid({
				rownumbers : true,
	            columns: [
	            { display: '商品ID', name: 'numIid', isSort : false, width: 100 },
	            { display: '商品标题', name: 'title',isSort : false, width: 400,
					render: function (record, rowindex, value, column){
						var html = '<a href="' + record.clickUrl + '" target="_blank">' + value + '</a>';
						return html; 
					}
	            },
	            { display: '价格', name: 'price',isSort : false, type : 'float', width: 100},
	            { display: '佣金', name: 'commission',isSort : false, type : 'float', width: 100},
	            { display: '佣金比例', name: 'commissionRate',isSort : false, type : 'float', width: 100 ,
	            	render: function (record, rowindex, value, column){
						var html = (value/100) + "%" ;
						return html; 
					}
	            },
	            { display: '所在地', name: 'itemLocation',isSort : false, width: 100 },
	            { display: '卖家呢称', name: 'nick',isSort : false, width: 100 },
	            { display: '图片', name: 'picUrl',isSort : false, width: 100,
					render: function (record, rowindex, value, column){
						var html = '<div><img src="' + value + '" width="100" height="100" onmouseover="picTipShow(this)" onmouseout="picTipHide()" /><img id="yuanTu" style="display: none;" src="' + value + '" /></div>';
						return html; 
					}
	            }
	            <c:if test="${name=='superMan'}">
	            ,{
                	display: '操作', 
                	name: 'numIid',
                	isAllowHide: false, 
                	isSort : false,
					render: function (record, rowindex, value, column){
						productArray.push(record);
						var html = '<a onclick="superUser('+value+')" href="javascript:;">分享</a>&nbsp;'; 
						return html; 
					}
                }
	            </c:if>
	            ], 
	            pageSize:20,
	            root :'taobaokeItems',
	            record:'totalResults',
	            url: "/misc/top/getproduct.htm",
	            width: '99%',height:'99%'
	        });
		
		$.ajax({url:"/misc/top/getcats.htm",
			success:function(data){
				var item_cat = data.itemCats;
				if(item_cat != null){
					 $.each(item_cat, function (i, cat) {
						 $("<option isparent='"+cat.isParent+"' value='"+cat.cid+"'>"+cat.name+"</option>").appendTo($("#root_cats"));
					 });
				}
			},
			type : 'get',
			dataType : 'json'
		});
	
		$("#root_cats").change(function(){
			changeSel(this,1);
		});
	
	});
	
	function changeSel(obj,i){
		var isparent = $(obj).find('option:selected').attr("isparent");
		if(isparent == 'true'){
			$(obj).nextAll().remove();
			$(obj).after("<select id='cats_"+i+"' name='cats"+i+"'></select>");
			
			
			
			var cidd = $(obj).val();
			$.ajax({url:"/misc/top/getcats.htm",data:{
						cid : cidd
					},
					success:function(data){
						var item_cat = data.itemCats;
						if(item_cat != null){
							 $.each(item_cat, function (j, cat) {
								 $("#cats_"+i).append("<option isparent='"+cat.isParent+"' value='"+cat.cid+"'>"+cat.name+"</option>");
								// $("<option isparent='"+cat.isParent+"' value='"+cat.cid+"'>"+cat.name+"</option>").appendTo($("#cats_"+i));
							 });
							 
							 $("#cats_"+i).change(function(){
								changeSel(this,i+1);
							});
						}
					},
					type : 'get',
					dataType : 'json'
				});
		}else{
			$(obj).nextAll().remove();
		}
	}

	function filterProduct(){
		var cids = null;
		$("#taobao_cat select").each(
			function(){
				cids = $(this).val();
			}
		);
		var startPrice = $("#start_price").val();
		var endPrice = $("#end_price").val();
		var autoSend = $("#auto_send").val();
		var area = $("#area").val();
		var startCredit = $("#start_credit").val();
		var endCredit = $("#end_credit").val();
		var sort = $("#sort").val();
		var guarantee = $("#guarantee").val();
		var startCommissionRate = $("#start_commissionRate").val();
		var endCommissionRate = $("#end_commissionRate").val();
		var startCommissionNum = $("#start_commissionNum").val();
		var endCommissionNum = $("#end_commissionNum").val();
		var startTotalnum = $("#start_totalnum").val();
		var endTotalnum = $("#end_totalnum").val();
		var cashCoupon = $("#cash_coupon").val();
		var vipCard = $("#vip_card").val();
		var overseasItem = $("#overseas_item").val();
		var sevendaysReturn = $("#sevendays_return").val();
		var realDescribe = $("#real_describe").val();
		var onemonthRepair = $("#onemonth_repair").val();
		var cashOndelivery = $("#cash_ondelivery").val();
		var mallItem = $("#mall_item").val();
		
		productGrid.options.parms = [{name:'cid',value:cids},
		                            {name:'startPrice',value:startPrice},
		                            {name:'endPrice', value : endPrice},
		                            {name:'autoSend', value : autoSend},
		                            {name:'area',value:area},
		                            {name:'startCredit',value:startCredit},
		                            {name:'endCredit',value:endCredit},
		                            {name:'sort',value:sort},
		                            {name:'guarantee',value:guarantee},
		                            {name:'startCommissionRate',value:startCommissionRate},
		                            {name:'endCommissionRate',value:endCommissionRate},
		                            {name:'startCommissionNum',value:startCommissionNum},
		                            {name:'endCommissionNum',value:endCommissionNum},
		                            {name:'startTotalnum',value:startTotalnum},
		                            {name:'endTotalnum',value:endTotalnum},
		                            {name:'cashCoupon',value:cashCoupon},
		                            {name:'vipCard',value:vipCard},
		                            {name:'overseasItem',value:overseasItem},
		                            {name:'sevendaysReturn',value:sevendaysReturn},
		                            {name:'realDescribe',value:realDescribe},
		                            {name:'onemonthRepair',value:onemonthRepair},
		                            {name:'cashOndelivery',value:cashOndelivery},
		                            {name:'mallItem',value:mallItem}];
		productGrid.loadData();
  }
	//弹出浮层显示图片
	function picTipShow(self,pic) {
		var thisTop = $(self).offset().top;
		var thisLeft = $(self).offset().left;
		var yuanTu = $(self).parent().find("#yuanTu");
		$("#pic_tip").css({
			top:thisTop,
			left:thisLeft+100,
			zIndex:1000,
			position:"absolute"
		});
		$("#pic_tip").html("<img width='200' height='200' src='"+yuanTu.attr("src")+"' />");
		$("#pic_tip").show();
	}
	function picTipHide() {
		$("#pic_tip").hide();
	}
	
	//打开超级帐号选择
	function superUser(id){
		for(var i=0; i<productArray.length; i++){
			if(productArray[i].numIid == id){
				product = productArray[i];
			}
		}
		if($("#back_share_product").size() < 1){
			$(document.body).append("<div id='back_share_product'></div>");
		}
		$("#back_share_product").load("/misc/top/toshareproduct.htm",{
			"id" : product.numIid
		},function(data){
			if(data == "same"){
				alert("亲，这个已经分享过了");
			}else{
				$.post("/misc/top/getproductinfo.htm", {
					id : product.numIid
				},function(data){
					//如果有图片列表
					if(data.imgs.length > 1){
						var imgsLi = "";
						for(var i=0; i<data.imgs.length; i++){
							if(i == 0){
								imgsLi += '<li style="display:block;" value="'+i+'"><img src="'+data.imgs[i].url+'" class="block" width="182" height="182"/></li>';
							}else{
								imgsLi += '<li style="display:none;" value="'+i+'"><img src="'+data.imgs[i].url+'" class="block" width="182" height="182"/></li>';
							}
						}
						$("#share_xinde_imgs").html(imgsLi);
					}else{
						$("#share_xinde_pic").attr("src",product.picUrl);
					}
				}, "json");
				$("#share_xinde_price").html("￥"+product.price);
				$("#share_xinde_title").html(product.title);
			}
		});
	}
	
</script>
<div id="pic_tip" onmouseover="javascript:$(this).show();" onmouseout="javascript:$(this).hide();"></div>
<div>
	<div>
		<table width="100%" class="def_t">
		<tr>
			<td>
				<div id="taobao_cat">
					商品类目：<select id="root_cats" name="rootCats"></select>
				</div>
			</td>
			<td>
				是否支持货到付款：<select id="cash_ondelivery" name="cashOndelivery">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
				<td>
				是否商城的商品：<select id="mall_item" name="mallItem">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
				<td>
				是否支持VIP卡：<select id="vip_card" name="vipCard">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
				<td>
				是否海外商品：<select id="overseas_item" name="overseasItem">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
		</tr>
		<tr>
			<td>
			商品价格：<input type="text" id="start_price" name="startPrice" style="width: 50px;"/> 到 <input type="text" id="end_price" name="endPrice" style="width: 50px;"/>
			</td>
			<td>
			是否自动发货：<select id="auto_send" name="autoSend">
							<option value=""></option>
							<option value="false">否</option>
							<option value="true">是</option>	
						</select>
			</td>
			<td>
			商品所在地：<input type="text" id="area" name="area" style="width: 100px;"/>
			</td>
			<td>
			卖家信用：<select id="start_credit" name="startCredit">
							<option value=""></option>
							<option value="1heart">一心</option>
							<option value="2heart">两心</option>
							<option value="3heart">三心</option>
							<option value="4heart">四心</option>
							<option value="5heart">五心</option>
							<option value="1diamond">一钻</option>
							<option value="2diamond">两钻</option>
							<option value="3diamond">三钻</option>
							<option value="4diamond">四钻</option>
							<option value="5diamond">五钻</option>
							<option value="1crown">一冠</option>
							<option value="2crown">二冠</option>
							<option value="3crown">三冠</option>
							<option value="4crown">四冠</option>
							<option value="5crown">五冠</option>
							<option value="1goldencrown">一黄冠</option>
							<option value="2goldencrown">二黄冠</option>
							<option value="3goldencrown">三黄冠</option>
							<option value="4goldencrown">四黄冠</option>
							<option value="5goldencrown">五黄冠</option>
						</select> 到 <select id="end_credit" name="endCredit">
							<option value=""></option>
							<option value="1heart">一心</option>
							<option value="2heart">两心</option>
							<option value="3heart">三心</option>
							<option value="4heart">四心</option>
							<option value="5heart">五心</option>
							<option value="1diamond">一钻</option>
							<option value="2diamond">两钻</option>
							<option value="3diamond">三钻</option>
							<option value="4diamond">四钻</option>
							<option value="5diamond">五钻</option>
							<option value="1crown">一冠</option>
							<option value="2crown">二冠</option>
							<option value="3crown">三冠</option>
							<option value="4crown">四冠</option>
							<option value="5crown">五冠</option>
							<option value="1goldencrown">一黄冠</option>
							<option value="2goldencrown">二黄冠</option>
							<option value="3goldencrown">三黄冠</option>
							<option value="4goldencrown">四黄冠</option>
							<option value="5goldencrown">五黄冠</option>
						</select>
				</td>
				<td>
				排序：<select id="sort" name="sort">
							<option value="default">默认排序</option>
							<option value="price_desc">价格从高到低</option>
							<option value="price_asc">价格从低到高</option>
							<option value="credit_desc">信用等级从高到低</option>
							<option value="commissionRate_desc">佣金比率从高到低</option>
							<option value="commissionRate_asc">佣金比率从低到高</option>
							<option value="commissionNum_desc">成交量成高到低</option>
							<option value="commissionNum_asc">成交量从低到高</option>
							<option value="commissionVolume_desc">总支出佣金从高到低</option>
							<option value="commissionVolume_asc">总支出佣金从低到高</option>
							<option value="delistTime_desc">商品下架时间从高到低</option>
							<option value="delistTime_asc">商品下架时间从低到高</option>
						</select>
				</td>
		 </tr>
		 <tr>
				<td>
				是否消保卖家：<select id="guarantee" name="guarantee">
							<option value=""></option>
							<option value="false">否</option>
							<option value="true">是</option>	
						</select>
				</td>
				<td>
				佣金比例：<input type="text" id="start_commissionRate" name="startCommissionRate" style="width: 50px;"/> 到 <input type="text" id="end_commissionRate" name="endCommissionRate" style="width: 50px;"/>
				</td>
				<td>
				30天累计推广量：<input type="text" id="start_commissionNum" name="startCommissionNum" style="width: 50px;"/> 到 <input type="text" id="end_commissionNum" name="endCommissionNum" style="width: 50px;"/>
				</td>
				<td>
				商品总成交量：<input type="text" id="start_totalnum" name="startTotalnum" style="width: 50px;"/> 到 <input type="text" id="end_totalnum" name="endTotalnum" style="width: 50px;"/>
				</td>
				<td>
				是否支持抵价券：<select id="cash_coupon" name="cashCoupon">
							<option value=""></option>
							<option value="false">否</option>
							<option value="true">是</option>	
						</select>
				</td>
			</tr>
			<tr>
				<td>
				是否支持7天退换：<select id="sevendays_return" name="sevendaysReturn">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
				<td>
				是否如实描述：<select id="real_describe" name="realDescribe">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
				<td>
				是否30天维修：<select id="onemonth_repair" name="onemonthRepair">
						<option value=""></option>
						<option value="false">否</option>
						<option value="true">是</option>	
					</select>
				</td>
				<td colspan="2">
					<input type="button" value="查询" onclick="filterProduct();"/>
				</td>
			</tr>
		</table>
	</div>
</div>
<div id="product_grid" style="margin:0; padding:0"></div>